Image region detection method, recording medium, and device therefor

ABSTRACT

Using an image region detection method according to the present invention, the detection of sides in the four directions (vertical and horizontal directions) is performed on the basis of results of edge detection performed on lines having a particular width, starting from an inner point toward the periphery of the quadrangular region in an input image, and the shape and the four corners of the quadrangle formed by the detected four sides are verified. Thereby, when there is a side that has been falsely detected, redetection on sides that are closer to the periphery than the side that has been detected falsely is performed, such that the quadrangular region can be formed at high speed.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to an image region detection technique forinputting, through an image input device, a printed image that includesan image in which prescribed codes are embedded, and detecting, on theinput image, a quadrangular region in which the codes are embedded.

2. Description of the Related Art

In recent years, techniques of embedding invisible codes in digital dataor in printed images have been developed. In order to read codeinformation from input images in which prescribed codes (simply referredto as “codes”, hereinafter) are embedded (the input images having beenphotographed by using image input devices such as cameras or scannersincluded in mobile phones), the coordinates of the four corners of thequadrangular region in which the codes are embedded are determined, anddecoding is performed on the basis of the determined coordinates of thefour corners.

In the conventional image region detection methods for detecting thecoordinates of four corners (such as those disclosed in, for example,Japanese Patent Application Publication Nos. 2005-277732 and2005-182164), the detection is performed in such a manner that theinitial coordinates from which the image region detection starts are setin the peripheral area of the input image, and the sides of thequadrangular region are thus detected; thereafter, the coordinates ofthe four corners are obtained to be used for the region detection.

In the conventional technique of detecting the four corners of thequadrangular region, searches for the sides of the quadrangular regionhave been performed from the peripheral area of the input image. Thus,when there is another quadrangular region that includes the quadrangularregion that has to be detected, this other, outer quadrangular region isdetected, and the inner quadrangular region that has to be detected isnot detected, which has been problematic.

SUMMARY OF THE INVENTION

It is an object of the present invention to properly detect aquadrangular region even when the quadrangular region is enclosed byanother quadrangular region. It is another object of the presentinvention to allow devices of low processing capacity, such as mobileterminals, to detect the coordinates of the four corners at high speed.

The image region detection method for detecting a quadrangular region ina second image, the second image being obtained by photographing aquadrangular first image, and the second image including thequadrangular region that is an image region corresponding to the firstimage in the present invention, comprises:

detecting one pixel, as a transition point, when a difference in pixelvalues between adjacent pixels exceeds a threshold value while scanningtoward a periphery of the second image from a plurality of pixels set asinitial points positioned within a certain range from a center of thesecond image;

creating sides of a quadrangle in respective combinations on the basisof transition points on the assumption that there is a combination oftransition points obtained in a one-by-one manner from respectivetransition point detection lines that are oriented in the same directionand that are members of a group of transition point detection lines thatare based on the transition point detection performed in four directionson the second image, the four directions being the two vertical and thetwo horizontal directions, and detecting as candidates for sides of thequadrangle, from among the sides created in the respective directions,those sides that are closest to the initial points; and

determining, on the basis of a quadrangle formed by the four candidatesides that have been detected, whether or not a detected side is a sidethat has been detected falsely, and performing redetection of candidatesfor sides when the side is confirmed to be a side that has been detectedfalsely.

The recording medium that records an image region detection program forcausing a computer to execute a process for detecting a quadrangularregion on a second image, the second image being obtained byphotographing a quadrangular first image and the second image includingthe quadrangular region that is an image region corresponding to thefirst image in the present invention, comprises:

a transition point detection process for detecting one pixel, as atransition point, when a difference in pixel values between adjacentpixels exceeds a threshold value while scanning toward a periphery ofthe second image from a plurality of pixels set as initial pointspositioned within a certain range from a center of the second image;

a four-sides-candidates detection process for creating sides of aquadrangle in respective combinations on the basis of transition pointson the assumption that there is a combination of transition pointsobtained in a one-by-one manner from respective transition pointdetection lines that are oriented in the same direction and that aremembers of a group of transition point detection lines that are based onthe transition point detection performed in four directions on thesecond image, the four directions being the two vertical and the twohorizontal directions, and detecting as candidates for sides of thequadrangle, from among the sides created in the respective directions,those sides that are closest to the initial points; and

a side redetection control process for determining, on the basis of aquadrangle formed by the four candidate sides that have been detected,whether or not a detected side has been detected falsely, and performingredetection of candidates for sides when the side is confirmed to be aside that has been detected falsely.

The image region detection device for detecting a quadrangular region ina second image, the second image being obtained by photographing aquadrangular first image, and the second image including thequadrangular region that is an image region corresponding to the firstimage in the present invention, comprises:

a transition point detection unit for detecting one pixel, as atransition point, when a difference in pixel values between adjacentpixels exceeds a threshold value while scanning toward a periphery ofthe second image from a plurality of pixels set as initial pointspositioned within a certain range from a center of the second image;

a four-sides-candidates detection unit for creating sides of aquadrangle in respective combinations on the basis of transition pointson the assumption that there is a combination of transition pointsobtained in a one-by-one manner from respective transition pointdetection lines that are oriented in the same direction and that aremembers of a group of transition point detection lines that are based onthe transition point detection performed in four directions on thesecond image, the four directions being the two vertical and the twohorizontal directions, and detecting as candidates for sides of thequadrangle, from among the sides created in the respective directions,those sides that are closest to the initial points; and

a side redetection control unit for determining, on the basis of aquadrangle formed by the four candidate sides that have been detected,whether or not a detected side is a side that has been detected falsely,and performing redetection of candidates for sides when the side isconfirmed to be a side that has been detected falsely.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows a configuration of an image region detection programaccording to the present invention;

FIG. 2 shows an arrangement on a sheet, the arrangement including animage in which the predetermined region is to be detected according tothe present invention;

FIG. 3 shows an example of an input image according to the presentembodiment;

FIG. 4A shows the principle of the present invention;

FIG. 4B shows the same sample as shown in FIG. 4A in a simplifiedmanner;

FIG. 5 shows false detection of a side according to the presentinvention;

FIG. 6 shows an example of a decode process, according to the presentembodiment, performed on the codes that are firstly embedded;

FIG. 7 shows a process flow for the code embedded region detectionprocess (S12) according to the present embodiment (example 1);

FIG. 8 shows a process flow of the code embedded region detectionprocess (S12) according to the present embodiment (example 2);

FIG. 9 shows an example of the transition point detection according tothe present embodiment;

FIG. 10 shows another example of the transition point detectionaccording to the present embodiment (in a case of which there are threecomponents);

FIG. 11 shows an example of a detection of sides according to thepresent embodiment;

FIG. 12 shows a detailed process flow of the four-side-candidatedetection process (S22) according to the present embodiment;

FIG. 13 shows in more detail the side-candidate detection process on therespective sides shown in FIG. 12;

FIG. 14 shows an example of shape verification according to the presentembodiment;

FIG. 15 shows in detail a process flow of the shape verification process(S24) according to the present embodiment;

FIG. 16 shows an example of the verification of four corners accordingto the present embodiment;

FIG. 17A shows an example (part1) of marks provided at the four cornersof the quadrangle according to the present embodiment;

FIG. 17B show an example (part2) of marks provided at the four cornersof the quadrangle according to the present embodiment;

FIG. 18 shows a detailed process flow for four corner verification (S26)according to the present embodiment;

FIG. 19 shows an example of the redetection of sides according to thepresent embodiment;

FIG. 20 shows a detailed process flow for a side redetection process(S28) according to the present embodiment; and

FIG. 21 shows a block diagram of a configuration of computer hardwareenvironment that executes the image region detection program accordingto the present embodiment.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

The image region detection method for detecting a quadrangular region ina second image, the second image being obtained by photographing aquadrangular first image, and the second image including thequadrangular region that is an image region corresponding to the firstimage in the present invention, n comprises:

detecting one pixel, as a transition point, when the difference in pixelvalues between adjacent pixels exceeds a threshold value while scanningtoward a peripheral region of the second image from a plurality ofpixels functioning as initial points positioned within a certain rangefrom a center portion of the second image;

creating sides of a quadrangle in respective combinations on the basisof transition points on the assumption that there is a combination oftransition points obtained in a one-by-one manner from respectivetransition point detection lines that are oriented in the same directionand that are members of a group of transition point detection lines thatare based on the transition point detection performed in four directionson the second image, the four directions being the two vertical and thetwo horizontal directions, and detecting as candidates for sides of thequadrangle, from among the sides created in the respective directions,those sides that are closest to the initial points; and

determining, on the basis of a quadrangle formed by the four candidatesides that have been detected, whether or not a detected side is a sidethat has been detected falsely, and performing redetection of candidatesfor sides when the side is confirmed to be a side that has been detectedfalsely.

By the above configuration, it is possible to detect the sides of aquadrangular region by employing transition point detection (edgedetection) starting from an inner point of the quadrangular region thatis included in an image. Accordingly, even when another quadrangle isarranged on the background region (outside of the target quadrangularregion), the target quadrangular region can be detected priorly.Accordingly, the quadrangle that is in the background region will not beerroneously detected. Also, the edge detection can be performed on onlya small number of lines in each direction, which enhances the speed ofthe edge detection.

In the above image region detection method, when the redetection ofcandidates for sides is performed:

the shape of the quadrangle formed by the four candidates detected forthe sides is verified, and thereby it is determined whether or not thereis a side that has been detected falsely among the four sides, and whenthere is a side that has been detected falsely, the side that has beendetected falsely is determined; and

distinguishing characteristics of the four corners of the quadrangleformed by the four sides are verified, and thereby it is determinedwhether or not there is a side that has been detected falsely among thefour sides, and when there is a side that has been detected falsely, itis determined which side has been detected falsely.

By the above configuration, when the sides are detected, the shape andthe four corners of the quadrangle formed by the detected four sides areverified, and the region formed by the four sides that have beendetermined to be the proper sides via the verification of sides andcorners can be handled as the target quadrangular region.

In the above image region detection method, when the redetection ofcandidates for sides is performed:

when the side that has been detected falsely is determined, a sidecreated on the basis of transition points in a nearest combination thatis closer than the side that has been detected falsely, to a peripheryof the second image is further detected as the candidate for the side.

By the above configuration, when there is a falsely detected side, thenext candidate for the side can be detected.

The above image region detection method further comprises:

detecting coordinates of the four corners of the quadrangle formed bythe four sides when there is no side that has been detected falsely.

By the above configuration, the sides that form the quadrangular regionare determined, and the intersections of the determined sides can behandled as the coordinates of the four corners.

In the above image region detection method:

when differences in pixel values between adjacent pixels on one and thesame transition point detection line are calculated, the differences arecalculated in a certain order for each component of respective pixelswhen the transition points are detected.

By the above configuration, it is possible to enhance the speed of thetransition point detection process and the detection efficiency.

In the above image region detection method:

a candidate for a side is an approximate line created on the basis oftransition points in the respective combinations, the approximate lineis within a certain distance of a tolerance from transition points fromwhich the approximate line was created, and the approximate line is theclosest approximate line to the initial point when the candidates forthe four sides are detected.

By the above configuration, even when there is a plurality ofcombinations of transition points (edges) that are in line, thecandidates for the sides of the target quadrangular region can benarrowed.

In the above image region detection method:

it is determined whether or not, among the four sides, there is a sidethat has been detected falsely, this determination being made, inverification of the shape of the quadrangle, on the basis of whether ornot an interior angle of the quadrangle formed by the four candidatesdetected for the sides is within a certain range.

By the above configuration, even when the first image is photographedobliquely such that the quadrangular region in the second image is atrapezoid, the sides that form the quadrangular region can be detected.

In the above image region detection method:

a distinguishing characteristic of each of the four corners of thequadrangle formed by the four sides is a shape of each of the fourcorners or a certain mark that is provided at each of the four cornersof the quadrangular region in order to be used for determining the firstimage in the verification of the distinctiveness of the four corners.

By the above configuration, it is possible to confirm whether or not thefour corners formed by the detected four sides are actually identical tothe four corners of the quadrangular region corresponding to the firstimage.

As described above, in the present invention, the detection of sides inthe four directions (vertical and horizontal directions) is performed onthe basis of results of edge detection performed on lines having aparticular width, starting from an inner point toward the periphery ofthe quadrangular region in the input image, and the shape and the fourcorners of the quadrangle formed by the detected four sides areverified. Thereby, when there is a side that has been falsely detected,redetection on sides that are closer to the periphery than the side thathas been detected falsely is performed, such that the quadrangularregion can be formed at high speed.

FIG. 1 shows a configuration of an image region detection programaccording to the present invention. The image region detection program 1detects a region of a quadrangular image in the photographed image. Theimage region detection program includes the steps of a transition pointdetection process (S1), a four-sides-candidates detection process (S2),a shape verification process (S3), a four corner verification process(S4), a sides redetection process (S5), a redetection control process(S6), and a four corner coordinate detection process (S7).

In the transition point detection process (S1), transition points(edges) at which the change in pixel values satisfies the predeterminedconditions are detected by searching in the four directions (verticaland horizontal directions) toward the periphery from an initial pointthat is located within a certain range from the center coordinate in theinput image.

Also in the transition point detection process (S1), it is possible forcomponents to be selected in the predetermined order at one and the samedetection point, and when the transition point is detected, thedetection at that point is terminated. Thereby, the transition pointdetection process is performed until the transition point is detected inorder of priority of a plurality of colors of components (colorcomponents that constitute pixels).

In the four-sides-candidates detection process (S2), the sides that arethe innermost in the respective directions are separately detected onthe basis of the detection results of the transition points.Specifically, in the four-sides-candidates detection process (S2), amongthe combinations of the transition points detected in the respectivedirections in the transition point detection process (S1), theapproximate lines whose distances from the respective coordinates of thetransition points are within the prescribed tolerance and which are theclosest to the initial point are the candidates for the sides of thequadrangular region (in other words, the sides are determined bycombining a plurality of inner transition points). Thereby, it ispossible to determine the sides on the basis of the combinations of theplurality of inner transition points obtained.

In the shape verification process (S3), the shape of the quadrangle thatconsists of the four sides detected in the four sides candidatesdetection process (S2) is verified. Further, in the shape verificationprocess (S3), it is determined whether there is a false detection of thefour sides, and when there is a false detection, the side that has beendetected falsely is determined. Specifically, it is determined whetheror not the respective four detections are false detections on the basisof whether or not the positions of the corners formed as theintersections between two sides among the four sides detected in the afour sides candidates detection process (S2) and the interior angles ofthe corners are within certain ranges. Thereby, the side that has beendetected falsely can be determined on the basis of the angles of thefour corners.

In the four corner verification process (S4), the likelihood of the fourcorners of the quadrangle formed by the detected four sides being thefour corners of the target quadrangle is verified. On the basis of theverification results, it is determined whether or not there is a falselydetected side among the four sides, and when there is a falsely detectedside, it is determined which side has been detected falsely. It ispossible to determine whether or not there is a side that has beendetected falsely, on the basis of, for example, whether or notdetections of the four corners of the quadrangle or detections of marksprovided for determining the four corners are terminated successfully.Thereby, it is possible to determine the side that has been detectedfalsely on the basis of the marks provided at the four corners or thelikelihood of the corners being the corners of the target quadrangle.

In the sides redetection process (S5), one outer side is newly detectedin the direction in which there is a side that has been detectedfalsely, the new detection being performed on the basis of thedetermination results of the shape verification process (S3) and thefour corner verification process (S4) and the result of the abovetransition point detection.

In the redetection control process (S6), it is determined whether or notany of the respective sides have been detected falsely, thedetermination being performed on the basis of the quadrangle formed bythe detected candidates for the four sides. When at least one side isdetermined to be a side that has been detected falsely, detection of thecandidates for that one side is again performed. Specifically, the shapeverification process (S3), the four corner verification process (S4),and the sides redetection process (S5) are performed until it isconfirmed that there is no side that has been detected falsely in theshape verification process (S3) or the four corner verification process(S4).

In the four corner coordinate detection process (S7), a quadrangularregion is detected on the basis of the four sides that are finallydetermined not to include a side that has been detected falsely in theredetection control process (S6).

Hereinbelow, the principle of the present invention will be explained.

FIG. 2 shows an arrangement on a sheet including an image on which thepredetermined region is to be detected in the present invention. Aninput image 11 includes a quadrangular region 12, and around theperiphery of the quadrangular region 12, there is a margin 13 having acertain width. Further out than the margin 13, there is a backgroundregion 14 on which there is no limitation of design or layout.

FIG. 3 shows an example of the input image in the present embodiment(the image is cited from JIS X 9201 CMYK/SCID). The input image 11 thatis obtained by photographing the sheet shown in FIG. 13 includes thequadrangular region 12 on which the region is to be detected, the margin13, and the background region 14. When a quadrangle 15 enclosing thequadrangular region 12 is included in the background region 14, theconventional detection methods cause a false detection detecting thatthe background region (the quadrangular region denoted by numeral 15) isthe quadrangular region that is the detection target.

FIG. 4A shows the principle of the present invention. FIG. 4B shows thesame sample as that shown in FIG. 14A in a simplified manner. FIG. 5shows the false detection of a side. In the present invention, the sidedetection is performed from an inner point in the quadrangular region 12by employing the edge detection as shown in FIGS. 4A and 4B;accordingly, even when the background region 14 includes the quadrangle15, the proper quadrangular region 12 can be detected prior to thedetection of the quadrangle 15, such that it is possible to avoidfalsely detecting quadrangle 15 as the detection target.

Also, when the detection of sides is performed from an inner pointtoward the periphery in the quadrangular region 12, a false detection ofa side that is not a side of the quadrangular region may be caused,depending on patterns of the image, as shown in FIG. 5.

Thus, when sides are detected, the shape of the quadrangle formed by thedetected four sides and the corners formed by the detected four sidesare verified. When the detected sides are determined to be the propersides through the above two kinds of verification, the region formed bythe four sides is handled as a provisional quadrangular region. If aside is determined to have been detected falsely, the next candidate forthe side that is closer to the periphery of the input image than theside that has been detected falsely is detected such that the quadrangleis modified. Thereby, the false detection is not caused in the inner orouter portion of the target quadrangular region such that thecoordinates of the four corners can be detected properly.

Next, the transition point detection process (S1), the shapeverification process (S3), the four corner verification process (S4),and the sides redetection process (S5) serving as the constituentelements of the redetection control function are explained in moredetail.

First, the transition point detection process (S1) is explained. Asdescribed above, in the transition point detection process (S1), theedge detection is performed from an inner point toward the periphery onthe image. When it is assumed that there is a difference greater than acertain value between the pixel value of the four sides of the targetquadrangular region and the pixel value of the margin, the positions ofthe four sides can be determined by employing the edge detection methodin which the difference between the value of the pixel of interest andthe value of the pixel around the pixel of interest is obtained.

However, when the edge detection is performed on all the pixels on theinput image, a large amount of calculation is required. In theconventional technique, the edge detection has been performed only on asmall number of lines from the periphery of the input image, and whenthe edge is detected, the detection direction is changed, and the edgedetection is performed along the detected edge in order to determine theside. This method allows high speed processing if the number ofdetection of edges performed before reaching the four sides is small.However, when the edge detection is performed from an inner point towardthe periphery, patterns in the target quadrangular region are detectedas edges, and the number of edge detection increases, such that processspeed is reduced.

Thus, in the present invention, the edge detection is performed only onthe small number of lines (five lines, for example) that are in eachsearch direction when the edge detection is performed from an innerpoint in the four directions (vertical and horizontal directions) inorder to realize a high speed edge detection.

Next, the four-sides-candidates detection process (S2) is explained.There is a difference greater than a certain value between the value ofthe pixels constituting the margin and the value of each of the pixelsconstituting the four sides of the target quadrangular region;accordingly, the edge can be detected no matter which point on the sidesthe edge detection is performed at.

Thus, a combination of the edges whose coordinates are approximately inline are selected from among the combinations of the edges that havebeen extracted in a one-by-one manner from the plurality of lines. Then,the proper combinations of the edges on the four sides of thequadrangular region are formed even in the case when there is aplurality of combinations of edges that are in line. Thereby, it ispossible to narrow the candidates for the sides of the quadrangularregion on the basis of the edge detection result.

Next, the shape verification process (S3) is explained. When the foursides detected in (S2) are proper, the angles of the four corners formedby the four sides are within the range of distortion of the trapezoidthat is assumed in the case when a quadrangular image is photographedwith a camera. Accordingly, it is verified whether or not the angles ofthe four corners are within the tolerance range, and when the angles areout of the tolerance range, the side that has the highest probability ofhaving been falsely detected is determined.

Specifically, when there is one side having two corners whose angles areboth out of the tolerance range, that side is determined to be the sidethat has been detected falsely. When there are two sides that each haveone or two corners whose angles are out of the tolerance, the side whoseangle with respect to the opposite side is larger is determined to bethe side that has been detected falsely. When there is an angle that isout of the tolerance range and any one of the above two conditions arenot satisfied, it is assumed that the quadrangular region has beenphotographed uninclined with respect to the input image, and the sidewhose angle with respect to one of the four sides of the input image isthe largest is determined to be the side that has been detected falsely.Thereby, the side that has been detected falsely is accuratelydetermined, and the detection accuracy of the quadrangular region isenhanced.

Next, the four corner verification process (S4) is explained.Distinguishing characteristics of the four corners (the shapes of thefour corners and the like) of the quadrangular region formed by thedetected four sides or the presence/absence of the mark indicating thepositions of the four corners is verified. When there is a falsedetection, the verification of the corner formed by the side that hasbeen detected falsely fails. Then, the side having the corners whoseverification failed is determined to be the side that has been detectedfalsely. By accurately determining the side that has been detectedfalsely, the detection accuracy of the quadrangular region is enhanced.

Next, the sides redetection process (S5) is explained. FIG. 5 shows aquadrangular region formed by T1, B1, L1, and R1. When the side R1 thathas been detected falsely is determined in the shape verificationprocess (S3) and four-corner verification process (S4), the side R2 thatis in the same direction as the edge detection line on which the edge ofthe origin of the side that has been detected falsely is detected andthat is next to the side that has been detected falsely in the directiontoward the center is handled as the new candidate for the side. In thismanner, the new quadrangular region formed by T1, B1, E1, and R2 isdetected. Thereby, coordinates of the four corners can be detectedwithout causing a false detection of a quadrangle inside the targetquadrangular region.

Hereinbelow, an embodiment is explained in which the quadrangular regionin which codes are embedded is properly detected without detecting aquadrangle that is arranged on the background region.

FIG. 6 shows an example of a decode process, in the present embodiment,performed on the codes that are firstly embedded. A CPU (CentralProcessing Unit) reads an image region detection program from arecording unit in a computer in which the recording unit records theimage region detection program, and executes the process in theflowchart shown in FIG. 6.

Electrical image data is created by photographing, with a camera, ascanner, or the like, an image in which codes are embedded. In an imageobtainment process (S11), the photographed image is obtained as an inputimage.

Next, in a code embedded region detection process (S12), the coordinatesof the four corners of a quadrangular region of an image in whichprescribed codes are embedded are determined for the input image whilefollowing the process flow.

In an embedded code read process (S13), the embedded codes are extractedfrom the rectangular image on the basis of the coordinates of the fourcorners.

Next, a detailed process flow (examples 1 and 2) for the code embeddedregion detection process (S12) is explained by referring to FIGS. 7 and8.

FIG. 7 shows a process flow for the code embedded region detectionprocess (S12) in the present embodiment (example 1). First, in (S11),the transition point detection (edge detection) is performed in the fourdirections (vertical and horizontal directions) on the image dataobtained in (S11). The candidates for the four sides are detected on thebasis of the detected transition points (edges) (S22).

Next, a redetection control process (S23) is performed. In theredetection control process (S23), the processes performed in (S24)through (S28) are controlled. The redetection control process (S23) isexplained in detail hereinbelow.

First, the shape of the quadrangle formed by the candidates for the foursides detected in (S22) is verified (S24). When a false detection isdetermined in (S24) (Yes in S25), the redetection of sides is performed(S28), and the shape is again verified (S24). When it is determined in(S24) that the shape of the quadrangle is proper and that there is nofalse detection (No in S25), the four corners are verified (S26).

When a false detection is determined to have occurred in verification ofthe four corners (S26) (Yes in S27), the redetection of sides isperformed (S28). The processes of S24 through S27 are repeated until itis determined that there is no side that has been detected falsely.

FIG. 8 shows a process flow chart of the code embedded region detectionprocess (S12) in the present embodiment (example 2). This flowchart isthe flowchart shown in FIG. 8 to which a four-corners-coordinates(intersections between four sides) detection process (S29) is added.When it is determined that there is no side that has been detectedfalsely (No in S27), the coordinates of the four corners at that momentare determined to be the coordinates of the four corners of thequadrangular region.

Next, the respective processes in the flowcharts shown in FIGS. 7 and 8are explained.

[Transition Point Detection in Four Directions (S21)]

FIG. 9 shows an example of the transition point detection in the presentembodiment. When the difference in pixel values between the pixel at thesearch point (the pixel at the point on which the edge detection iscurrently being performed) and a pixel around the search point exceeds acertain threshold value, the pixel at that search point is handled asthe transition point (edge) by utilizing the fact that there is adifference in pixel values between the four sides of the quadrangularregion 12 and the margin 13 around the quadrangular region 12. In FIG.9, the filled circles on the edge detection lines denote the edges(transition points) at which the pixel value changes from “dark” to“bright”.

The transition point detection (edge detection) is performed in the fourdirections from an inner point on the quadrangular region 12 toward theperiphery of the input image 11. For example, a region around the centerof the input image 11 is set as the initial coordinates for the edgedetection in the four directions on the assumption that the quadrangularregion 12 surrounds the center of the input image 11. This edgedetection is performed on, for example, five lines in each of the fourdirections (vertical and horizontal directions), as shown in FIG. 9.

It is also possible to detect only the edges that include flat pixelswhose width is smaller than that of the margin 13 being assumed in theinput image 11 (in other words, only the edge being detected and havingthereafter the region of a prescribed width in which there is almost nodifference in the pixel values between the pixel being in the searchedposition and another pixel around it), in order to accurately performdetection by reducing the number of edges detected.

FIG. 10 shows another example of the transition point detection in thepresent embodiment (in a case in which there are three components).According to this example, it is possible to enhance the processingspeed of the transition point detection and the detection efficiency.

Each pixel consists of the three components, R (red), G (green), and B(blue). Thus, in the process flow shown in FIG. 10, transition points(edges) are detected for each component. For the convenience of theexplanation on this flowchart, it is assumed that the coordinate of thepixel that is the target of a search is X1 (x, y), and the coordinate ofthe pixel next to this pixel is X2 (x+1, y) on, for example, the edgedetection line to the right direction.

First, the transition point (edge) of component 1 of X1 and X2 isdetected (S21-1). In the detection of the transition point (edge), whenthe difference in the pixel values of component 1 exceeds a certainthreshold value, the pixel at that moment is handled as the transitionpoint (edge).

When the transition point is detected in S21-1, in other words, when thedifference in the pixel values between component 1 of X1 and component 1of X2 exceeds the threshold value (Yes in S21-2), the position of thattransition point is recorded (S21-9). Thereafter, the process proceedsto S21-7.

When the transition point is not detected in S21-1—in other words, whenthe difference in the pixel values between component 1 of X1 andcomponent 1 of X2 does not exceed the threshold value (No in S21-2)—thetransition points (edges) of component 2 of X1 and of component 2 of X2are detected (S21-3).

When the transition point is detected in S21-3—in other words, when thedifference in the pixel values between component 2 of X1 and component 2of X2 exceeds the threshold value (Yes in S21-4)—the position of thattransition point is recorded (S21-9). Thereafter, the process proceedsto S21-7.

When the transition point is not detected in S21-3—in other words, whenthe difference in the pixel values between the component 2 of X1 and thecomponent 2 of X2 does not exceed the threshold value (No in S21-4)—thetransition points (edges) of component 3 of X1 and component 3 of X2 aredetected (S21-5).

When the transition point is detected in S21-5—in other words, when thedifference in the pixel values between component 3 of X1 and component 3of X2 exceeds the threshold value (Yes in S21-6)—the position of thattransition point is recorded (S21-9). Thereafter, the process proceedsto S21-7.

When the transition point is not detected in S21-5—in other words, whenthe difference in the pixel values between component 3 of X1 andcomponent 3 of X2 does not exceed the threshold value (No in S21-6)—itis determined whether or not the searched point (i.e., the position ofX1) has reached the end of the input image 11 (S21-7).

When it is determined in S21-7 that the searched point (the position ofX1) has not reached the end of the input image 11 (No in S21-7), thesearched point X1 is moved by 1 pixel to the right direction along theedge detection line, such that X1 is (x+1, y) and X2 is (x, y). Theprocess of S21-1 is again performed on the new X1 and X2.

When it is determined in S21-7 that the searched point (the position ofX1) has reached the end of the input image 11 (Yes in S21-7), thisprocess flow is terminated.

[Four Side Candidate Detection Process (S22)]

FIG. 11 shows an example of a detection of sides in the presentembodiment. The coordinates detected by the edge detection on five linesto the right direction are thought to be approximately in line along aside as shown in FIG. 9, when the coordinates are close to a side of thequadrangular region.

Accordingly, the coordinates of the transition points (edge coordinates)detected on the respective edge detection lines in the respectivedirections are combined, the approximate line is calculated from thecoordinates of the transition points of the combination by employing theleast-square method, and another approximate line whose transition pointcoordinates are closer to the approximate line than the certain distanceis detected as a candidate for a side.

When there is a plurality of candidates for the right side as shown inFIG. 11, the priority order is determined, starting from the candidateclosest to the initial point of the edge detection as R1, R2, and R3,and R1 is employed as the right side of the quadrangular region.

The above processes are performed in the four directions (vertical andhorizontal directions), such that four sides are detected as the upper,lower, left, and right sides. Thereby, the provisional quadrangularregion is detected. This process is explained by referring to FIGS. 11and 12.

FIG. 12 shows a detailed process flow of the four side candidatedetection processes (S22) in the present embodiment. In FIG. 12, thedetection of candidates for sides shown in FIG. 13 is performed on theupper, lower, left, and right sides (S22-1, S22-2, S22-3, and S22-4).These processes of S22-1 through S22-4 can be performed in an arbitraryorder.

FIG. 13 shows in more detail the side candidate detection process on therespective sides shown in FIG. 12. First, the coordinates of theinnermost transition point (the closest transition point to the centerof the input image 11) is acquired among the combinations of thecoordinates of the transition points detected in the respectivedirections, and the combination of these coordinates of the transitionpoints is selected (S22-n 1, where n=1 through 4).

Next, the approximate line is calculated from the selected combinationof the coordinates of the transition points by employing theleast-square method (S22-n 2).

Next, it is determined whether or not the length between each of thecoordinates of the transition point and the approximate line is withinthe tolerance range (S22-n 3). When the length between each of thecoordinates of the transition points and the approximate line>thetolerance range (No in S22-n 3), the combination of the coordinates ofthe transition points that are next to the current combination on theside closest to the center are selected (S22-n 4), and the process inS22-n 2 is performed. When the combination of the coordinates of thetransition points is selected, a new set of coordinates of thetransition points can be selected by replacing the coordinates of thetransition points that satisfy “length between each of the coordinatesof the transition points and approximate line>tolerance range” with thecoordinates of the transition points on the same edge detection linethat is next to the current transition point on the side closest to thecenter (in other words, a new combination of transition points iscreated by replacing each of the coordinates). In addition, acombination of the coordinates of the transition points that are next to(on the side closest to the center) the coordinates of a set of thetransition points that served as the origin of the approximate line canbe the new set of coordinates (in other words, the approximate line iscreated by replacing each of combinations that are currently selected).

When each of the coordinates of the transition points≦tolerance range(Yes in S22-n 3), the approximate line is determined to be the candidatefor a side (S22-n 5).

[Shape Verification Process (S24)]

FIG. 14 shows an example of shape verification in the presentembodiment. In the shape verification process (S24), the angles a, b, c,and d of the four corners formed by the sides T1, B1, L1, and R1 formingthe provisional quadrangular region are obtained.

It is assumed that the range of variations (which are caused by aninclination of the camera with respect to the image photographed by thecamera) of the angle (which should be 90 degrees) of each of the cornersof the image in which the codes are embedded is between, for example 80degrees and 100 degrees. On the basis of this assumption, if the angleat the intersection between the detected sides is within the rangebetween 80 degrees and 100 degrees, that angle is determined to bewithin the tolerance range of the corners of the quadrangular regionthat satisfies the requirement of the shape verification.

When there is an angle that is not within the tolerance range, the angleverification is determined to have failed, and it is determined that oneof the two sides including the angle is a side that has been detectedfalsely.

Further, when the angle verification on another angle fails and there isa side that is common for those two angles, that side is determined tobe a side that has been detected falsely.

When there is an angle for which the verification fails and thecandidates for the angle that has been detected falsely cannot benarrowed, the side that has the highest probability of being the sidethat has been detected falsely is determined on the basis of theparallelism against the opposite side and the parallelism against theinput image. Thereafter, the detection is again performed.

In FIG. 14, the angle a formed by L1 and T1, and the angle b formed byL1 and B1 are within the tolerance range of a quadrangle, thus the angleverifications on these angles are successful. In contrast, the angle cformed by T1 and R1, and the angle d formed by B1 and R1 are not withinthe tolerance, thus the R1 is determined to be a side that has beendetected falsely because the angle verification on the angle included inthat side failed. This process is explained by referring to FIG. 15.

FIG. 15 shows in detail a process flow of the shape verification process(S24) according to the present embodiment. First, the angles of the fourcorners of the quadrangle formed by the four sides are calculated(S24-1).

Next, it is determined whether all the angles of the four corners arewithin the tolerance range, or whether there are two angles that are notincluded in one side and that are out of the tolerance range (condition1-1). When condition 1-1 is satisfied (Yes in S24-2), it is determinedthat there has been no false detection (S24-6).

When condition 1-1 is not satisfied (No in S24-2), it is determinedwhether there are two angles that are included in one side and that areout of the tolerance range (condition 1-2). When condition 1-2 issatisfied (Yes in S24-3), the corresponding side is determined to be aside that has been detected falsely (S24-7).

When condition 1-2 is not satisfied (No in S24-3), it is determinedwhether there is one or three angles that are out of the tolerance(condition 1-3) (S24-4). When condition 1-3 is satisfied (Yes in S24-4),a side that has been detected falsely is determined on the basis of thecalculation of the angle with respect to the opposite side (S24-8).Specifically, the side that has the highest probability of being thathas been detected falsely is determined on the basis of the parallelismagainst the opposite side (when the angle against the opposite side isgreater than a prescribed angle).

When condition 1-3 is not satisfied (No in S24-4), it is determinedwhether all the angles are out of the tolerance range (condition 1-4)(S24-5). When condition 1-4 is satisfied (yes in S24-5), the side thathas been detected falsely is determined by the calculation of the angleof the input image (S24-9). Specifically, the side that has the highestprobability of being a falsely detected side is determined on the basisof the parallelism respectively against the sides forming the quadrangleand the sides forming the frame of the input image.

When condition 1-4 is not satisfied (No in S24-5), or when the processesof S24-6 through S24-9 are terminated, this process flow is terminated.

[Four Corner Verification (S26)]

FIG. 16 shows an example of the verification of the four cornersaccording to the present embodiment. By verifying the four corners, itis determined that among the four sides, there is a side that has beendetected falsely in the quadrangular region 12, and that the quadrangleformed by the four sides is proper.

In the verification of the four corners, the distinguishingcharacteristics (L-shaped patterns that form the respective corners ofthe quadrangle, for example) of the quadrangle in which codes areembedded or marks are provided at the four corners are detected.

FIGS. 17A and 17B show an example of marks provided at the four cornersof the quadrangle in the present embodiment. The four corners areverified on the basis of the presence/absence of the distinguishingcharacteristics such as the crosses shown. When there is a corner thatdoes not have a distinguishing characteristic, the four cornerverification is determined to have failed, and one of the two adjacentsides is determined to be the falsely detected side. Further, when thefour corner verification of another corner fails and there is a sidethat is shared by two corners that have been detected falsely, the sideis determined to be the side that has been detected falsely. When thereis a corner whose verification failed and the side that has beendetected falsely can not be determined, the side having the highestprobability of being a falsely detected side is determined on the basisof its parallelism against the opposite side and its parallelism againstthe input image, similarly to the case of the shape verification.Thereafter, side detection is again performed.

FIG. 18 shows a detailed process flow for the four corner verification(S26) in the present embodiment. First, the distinguishingcharacteristics of the four corners of the quadrangle are detected(S26-1). This detection of the distinguishing characteristics isperformed by, for example, determining whether or not the shape of eachcorner is L-shaped, or whether or not each of the four corners has aprescribed mark such as a cross (FIG. 17B).

Next, it is determined whether detection of the distinguishingcharacteristics of the four corners succeeded, or whether thedistinguishing characteristics of two corners that are not both includedin one side failed (condition 2-1). When condition 2-1 is satisfied (Yesin 26-2), it is determined that there has been no false detection(S26-6).

When condition 2-1 is not satisfied (No in S26-2), it is determinedwhether the detection of distinguishing characteristics of two cornersincluded in one side failed (condition 2-2). When condition 2-2 issatisfied (Yes in S26-3), the corresponding side is determined to be aside that has been detected falsely (S24-7).

When condition 2-2 is not satisfied (No in 526-3), it is determinedwhether the detection of distinguishing characteristics of one or threecorners failed (condition 2-3) (S26-4). When condition 2-3 is satisfied(Yes in S26-4), the side that has been detected falsely is determined onthe basis of the calculation of the angle against the opposite side.Specifically, the side that has the highest probability of having beendetected falsely is determined on the basis of its parallelism againstthe opposite side (when the angle against the opposite side is greaterthan a prescribed angle).

When condition 2-3 is not satisfied (No in S26-4), it is determinedwhether the detection of distinguishing characteristics of all theangles failed (condition 2-4) (S26-5). When condition 2-4 is satisfied(Yes in S26-5), the side that has been detected falsely is determined bythe calculation of the angle against the input image (S26-9).Specifically, the side that has the highest probability of having beendetected falsely is determined on the basis of its parallelismrespectively against the sides forming the quadrangle and the sidesforming the frame of the input image.

When condition 2-4 is not satisfied (No in S26-5), or when the processesin S26-6 through S26-9 are terminated, the present process flow isterminated.

[Side Redetection Process (S28)]

FIG. 19 shows an example of the redetection of sides in the presentembodiment. As shown in FIG. 19, when it is determined that there is afalse detection in the shape verification process (S24) or in the fourcorner verification (S26) and the side R1 that is the side that has beendetected falsely is determined, the side R2 that is closer to theperiphery than the side R1 and that is detected by the process ofdetection of a side next to the side R1 is handled as the new side, andthe provisional quadrangle is modified into the quadrangle formed by T1,B1, L1, and R2.

FIG. 20 shows a detailed process flow for the side redetection process(S28) in the present embodiment. First, the combination of thecoordinates of the transition points on which the false detectionoccurred are recorded (S28-1l. Next, the coordinates of the transitionpoints that are on the respective edge detection lines and that are nextto (on the side closest to the center) the transition points whosecoordinates were recorded in S28-1 are obtained, and a combination ofthese transition points is selected (S28-2).

Next, the approximate line is calculated from the selected combinationof the coordinates of the transition points by employing theleast-square method (S28-3).

Next, it is determined whether or not the length between each of thecoordinates of the transition points and the approximate line is withinthe tolerance (S28-4). When the length between each of the coordinatesof the transition points and the approximate line>tolerance range (No inS28-4), the combination of the coordinates of the transition points thatare next to the current combination on the side closest to the center isselected (S28-2), and the process in S28-3 is performed. When thecombination of the coordinates of the transition points is selected, anew single set of the coordinates of the transition points can beselected by replacing the coordinates of the transition points thatsatisfy “length between each of the coordinates of the transition pointsand approximate line>tolerance range” with the coordinates of thetransition points on the same edge detection line that is next to thecurrent transition point on the side closest to the center; in addition,a combination of the coordinates of the transition points that are nextto (on the side closest to the center) the coordinates of a set of thetransition points that served as the origin of the approximate line canbe the new single set of coordinates of the transition points.

When the length between each transition point coordinate≦tolerance (Yesin S28-4), the approximate line is determined to be the candidate for aside (S28-5).

FIG. 21 shows a block diagram of a configuration of a hardwareenvironment of a computer that executes the image region detectionprogram in the present embodiment. In FIG. 21, a computer 20 includes aCPU 22, a read only memory (ROM) unit 23, a random access memory (RAM)unit 26, a communication interface (hereinafter, referred to as an I/F)24, a recording unit 27, an output I/F 21, an input I/F 25, atransportable recording medium reading device 28, a bus 29 to which allthe above components are connected, an output device 30 connected to theoutput I/F 21, and an input device 31 connected to the input I/F 25.

As the recording unit 27, various types of recording devices such as ahard disk, a magnetic disk, a flash memory unit and the like can beused. The program based on the above flowcharts explained in the aboveembodiments are recorded in the recording unit 27 or the ROM unit 23.Also, the threshold values, the patterns used for the shape detection,and the distinguishing characteristics detection used in the aboveembodiments are recorded in the recording unit 27.

The program according to the present embodiment can be recorded in, forexample, the recording unit 27, being provided by a program providingparty through a network 32 or the communication I/F 24. Also, thisprogram can be executed by the CPU 22, being recorded in a commerciallyavailable transportable recording medium, and read by the transportablerecording medium reading device 28. As the transportable recordingmedium, various types of recording media such as CD-ROM, a flexibledisk, an optical disk, a magneto-optical disk, and an IC card can beused, and the program recorded in such a recording medium is read by thetransportable recording medium reading device 28.

Also, as the input device 31, a keyboard, a mouse, an electronic camera,a microphone, a scanner, a sensor, a tablet, or the like can be used.Also, as the output device 30, a display device, a printer, a speakersystem, or the like can be used. Also, the network 32 can be acommunication network such as the Internet, a LAN, a WAN, dedicatedlines, a wired network, a wireless network, a public line network, orthe like.

According to the conventional techniques of the image region detectionmethod for detecting images in which codes are embedded, regiondetection fails depending on the designs and arrangements of backgroundregions. However, according to the image region detection methodaccording to the present invention, the target regions can be properlydetected without being influenced by designs or arrangements ofbackground regions, such that the degrees of freedom in designing and inthe arrangement of the sheet including images in which codes areembedded are enhanced. Also, the lower amount of calculation allowshigh-speed detection of regions; thus, the present invention can beapplied also to devices with low processing capacities such as PDAs(Personal Digital Assistants) or mobile phones.

In the present embodiment, an example has been explained in which aquadrangular region corresponding to the first image in which codes areembedded is detected on the second image. However, the scope of thepresent invention is not limited to this example, and the first imagedoes not have to include the codes embedded therein when distinguishingcharacteristics of the four corners are used for the detection of thefirst image.

The scope of the present invention is not limited to the aboveembodiments, and various configurations and forms may be employedwithout departing from the spirit of the present invention.

By applying the present invention, even when the quadrangle that has tobe detected is included in another quadrangle, it is possible toproperly detect the inner quadrangle that is the detection target. Also,by applying the present invention, even devices that have low processingcapacities such as mobile terminals can detect the coordinates of thefour corners at high speed.

1. An image region detection method for detecting a quadrangular regionin a second image, the second image being obtained by photographing aquadrangular first image, and the second image including thequadrangular region that is an image region corresponding to the firstimage, comprising: detecting one pixel, as a transition point, when adifference in pixel values between adjacent pixels exceeds a thresholdvalue while scanning toward a periphery of the second image from aplurality of pixels set as initial points positioned within a certainrange from a center of the second image; creating sides of a quadranglein respective combinations on the basis of transition points on theassumption that there is a combination of transition points obtained ina one-by-one manner from respective transition point detection linesthat are oriented in the same direction and that are members of a groupof transition point detection lines that are based on the transitionpoint detection performed in four directions on the second image, thefour directions being the two vertical and the two horizontaldirections, and detecting as candidates for sides of the quadrangle,from among the sides created in the respective directions, those sidesthat are closest to the initial points; and determining, on the basis ofa quadrangle formed by the four candidate sides that have been detected,whether or not a detected side is a side that has been detected falsely,and performing redetection of candidates for sides when the side isconfirmed to be a side that has been detected falsely.
 2. The imageregion detection method according to claim 1, wherein, in the case whenthe redetection of candidates for sides is performed: a shape ofquadrangle formed by the four candidates detected for the sides isverified, and thereby it is determined whether or not there is the sidethat has been detected falsely among the four sides, and when there isthe side that has been detected falsely, the side that has been detectedfalsely is determined; and distinguishing characteristics of the fourcorners of the quadrangle formed by the four sides are verified, andthereby it is determined whether or not there is the side that has beendetected falsely among the four sides, and when there is the side thathas been detected falsely, the side that has been detected falsely isdetermined.
 3. The image region detection method according to claim 2,wherein, in the case when the redetection of candidates for sides isperformed: when the side that has been detected falsely is determined, aside created on the basis of transition points in a nearest combinationthat is closer than the side that has been detected falsely, to aperiphery of the second image is further detected as the candidate forthe side.
 4. The image region detection method according to claim 1,further comprising: detecting coordinates of four corners of thequadrangle formed by the four sides when there is no side that has beendetected falsely.
 5. The image region detection method according toclaim 1, wherein: in the case when differences in pixel values betweenadjacent pixels on one and the same transition point detection line arecalculated, the differences are calculated in certain order for each ofcomponents of respective pixels when the transition points are detected.6. The image region detection method according to claim 1, wherein: acandidate for a side is an approximate line created on the basis oftransition points in the respective combinations, the approximate lineis within a certain distance of a tolerance from transition points fromwhich the approximate line was created, and the approximate line is theclosest approximate line to the initial point when the candidates forthe four sides are detected.
 7. The image region detection methodaccording to claim 2, wherein: it is determined whether or not, amongthe four sides, there is the side that has been detected falsely, thisdetermination being made, in verification of the shape of thequadrangle, on the basis of whether or not an interior angle of thequadrangle formed by the four candidates detected for the sides iswithin a certain range.
 8. The image region detection method accordingto claim 2, wherein: a distinguishing characteristic of each of the fourcorners of the quadrangle formed by the four sides is a shape of each ofthe four corners or a certain mark that is provided at each of the fourcorners of the quadrangular region in order to be used for determiningthe first image in the verification of the distinctiveness of the fourcorners.
 9. A recording medium that records an image region detectionprogram for causing a computer to execute a process for detecting aquadrangular region on a second image, the second image being obtainedby photographing a quadrangular first image and the second imageincluding the quadrangular region that is an image region correspondingto the first image, comprising: a transition point detection process fordetecting one pixel, as a transition point, when a difference in pixelvalues between adjacent pixels exceeds a threshold value while scanningtoward a periphery of the second image from a plurality of pixels set asinitial points positioned within a certain range from a center of thesecond image; a four-sides-candidates detection process for creatingsides of a quadrangle in respective combinations on the basis oftransition points on the assumption that there is a combination oftransition points obtained in a one-by-one manner from respectivetransition point detection lines that are oriented in the same directionand that are members of a group of transition point detection lines thatare based on the transition point detection performed in four directionson the second image, the four directions being the two vertical and thetwo horizontal directions, and detecting as candidates for sides of thequadrangle, from among the sides created in the respective directions,those sides that are closest to the initial points; and a sideredetection control process for determining, on the basis of aquadrangle formed by the four candidate sides that have been detected,whether or not a detected side has been detected falsely, and performingredetection of candidates for sides when the side is confirmed to be aside that has been detected falsely.
 10. The recording medium accordingto claim 9, wherein the side redetection control process comprises: ashape verification process for determining whether or not there is theside that has been detected falsely among the four sides on the basis ofthe shape of the quadrangle formed by the four candidates detected forthe sides, and determining the side that has been detected falsely whenthere is the side that has been detected falsely; and a four cornerverification process for determining whether or not there is the sidethat has been detected falsely among the four sides on the basis of thedistinguishing characteristics of the four corners of a quadrangleformed by the four candidates detected for the sides, and determiningthe side that has been detected falsely when there is a side that hasbeen detected falsely.
 11. The recording medium according to claim 10,wherein the side redetection control process further comprises: a sideredetection process for detecting, as a candidate for the side, a sidethat is created on the basis of transition points in a nearestcombination that is closer than the side that has been detected falselyto a periphery of the second image when the side that has been detectedfalsely is determined.
 12. The recording medium according to claim 9,wherein the recording medium further comprises: a four corner coordinatedetection process for detecting coordinates of four corners of aquadrangle formed by the four sides when there is no side that has beendetected falsely.
 13. The recording medium according to claim 9,wherein: the transition point detection process calculates, in a certainorder, differences in pixel values for each component of pixels when thedifferences in pixel values between adjacent pixels on the sametransition point detection line are calculated.
 14. The recording mediumaccording to claim 9, wherein: in the four-sides-candidates detectionprocess, a candidate for a side is an approximate line created on thebasis of transition points in the respective combinations, theapproximate line is within a certain distance of a tolerance range fromtransition points from which the approximate line was created, and theapproximate line is the closest approximate line the initial point. 15.The recording medium according to claim 10, wherein: in the shapeverification process, it is determined whether or not there is the sidethat has been detected falsely among the four sides on the basis ofwhether or not an interior angle of the quadrangle formed by the fourcandidates detected for the sides is within a certain range.
 16. Therecording medium according to claim 10, wherein: in the four cornerverification process, the distinguishing characteristic of the fourcorners of the quadrangle formed by the four sides is a shape of each ofthe four corners or a certain mark that is provided at four corners ofthe quadrangular region in order to be used for determining the firstimage.
 17. An image region detection device for detecting a quadrangularregion in a second image, the second image being obtained byphotographing a quadrangular first image, and the second image includingthe quadrangular region that is an image region corresponding to thefirst image, comprising: a transition point detection unit for detectingone pixel, as a transition point, when a difference in pixel valuesbetween adjacent pixels exceeds a threshold value while scanning towarda periphery of the second image from a plurality of pixels set asinitial points positioned within a certain range from a center of thesecond image; a four-sides-candidates detection unit for creating sidesof a quadrangle in respective combinations on the basis of transitionpoints on the assumption that there is a combination of transitionpoints obtained in a one-by-one manner from respective transition pointdetection lines that are oriented in the same direction and that aremembers of a group of transition point detection lines that are based onthe transition point detection performed in four directions on thesecond image, the four directions being the two vertical and the twohorizontal directions, and detecting as candidates for sides of thequadrangle, from among the sides created in the respective directions,those sides that are closest to the initial points; and a sideredetection control unit for determining, on the basis of a quadrangleformed by the four candidate sides that have been detected, whether ornot a detected side is a side that has been detected falsely, andperforming redetection of candidates for sides when the side isconfirmed to be a side that has been detected falsely.
 18. The imageregion detection device according to claim 17, wherein the sideredetection control unit comprises: a shape verification unit fordetermining whether or not there is the side that has been detectedfalsely among the four sides on the basis of the shape of the quadrangleformed by the four candidates detected for the sides, and determiningthe side that has been detected falsely when there is the side that hasbeen detected falsely; and a four corner verification unit fordetermining whether or not there is the side that has been detectedfalsely among the four sides on the basis of the distinguishingcharacteristics of the four corners of a quadrangle formed by the fourcandidates detected for the sides, and determining the side that hasbeen detected falsely when there is a side that has been detectedfalsely.
 19. The image region detection device according to claim 18,wherein the side redetection control unit further comprises: a sidedetection unit for detecting, as a candidate for the side, a side thatis created on the basis of transition points in a nearest combinationthat is closer than a side that has been detected falsely to a peripheryof the second image when the side that has been detected falsely isdetermined.
 20. The image region detection device according to claim 17,further comprising: a four corner coordinate detection unit fordetecting coordinates of four corners of the quadrangle formed by thefour sides when there is no side that has been detected falsely.